<?php
class UsersController extends AppController {

	var $name = 'Users';
	var $components = array('Auth');
	
	//Authorization things.
	function beforeFilter() {
        $this->Auth->allow('index','view', 'add');
	}
	

	function index() {
		$this->set('users', $this->User->find('all'));
	}
	
	function view($id = null) {
		$this->User->id = $id;
		$this->set('user', $this->User->read());
		$this->set('votesFor', $this->User->Vote->find('all', 
				array('conditions' => array('User.id' => $this->User->id))));
	}
	
	function add() {
		if (!empty($this->data)) {
			if ($this->User->save($this->data)) {
				$this->Session->setFlash('A new user has been saved.');
				$this->redirect(array('action' => 'index'));
			}
		}
	}
	
	function login() {
    }

    function logout() {
        $this->redirect($this->Auth->logout());
    }
	
	function settings() {
		
	}
}
?>